<?php
namespace Admin\Controller;
use Think\Controller;
class AdminController extends Controller
{
    public function _empty(){
       echo "没有此方法";
    }
    public function __construct(){
        parent::__construct();//继承构造方法
//        session('admin');
        if(empty(session('admin'))){
            $this->error('请先登录',U('Login/index'));
        }else{
            $admin_name = session('name');
            $this->assign('admin_name',$admin_name);
        }

    }

    function get_img_url($url, $basename, $size=250)
    {
        switch ($size) {
            case 350:
                $pre = '350_';
                break;
            case 250:
                $pre = '250_';
                break;
            case 150:
                $pre = '150_';
                break;
            case 50:
                $pre = '50_';
                break;
            case 30:
                $pre = '30_';
                break;
            default:
                $pre = null;
                break;
        }

        $imgpath = rtrim($url,'/').'/';
        $imgpath .= substr($basename,0,4).'/';
        $imgpath .= substr($basename,4,2).'/';
        $imgpath .= substr($basename,6,2).'/';
        $imgpath .= $pre .$basename;

        return $imgpath;
    }


}